/**
 * Created by zhaobo on 2016/12/22.
 */
import React, {Component} from "react";
import {
  AppRegistry,// AppRegistry的内置模块进行了“注册”操作
  StyleSheet,// 集中定义组件的样式
  Text,
  View,
  Image,
  ListView,
  TextInput,
  ScrollView,
  Navigator,
  TouchableHighlight,
  TouchableOpacity,
  TouchableNativeFeedback,
  NativeModules,
} from "react-native";

class MText extends Component {
  constructor(props) {
    super(props);
    this.state = {showText: true};

    setInterval(() => {
      this.setState({showText: !this.state.showText});
    }, 1000)
  }

  render() {
    let display = this.state.showText ? this.props.text : ' ';
    return (
      <Text style={styles.red}>{display}</Text>
    );
  }
}
//export default 导出当前组件 允许其他组件引入(import)和使用当前组件
export default class MyProject extends Component {
  render() {
    let pic = {
      uri: 'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'
    };
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Welcome to React Native!
        </Text>
        <Text style={styles.instructions}>
          To get started, edit index.android.js
        </Text>
        <Text style={[styles.instructions, styles.red]}>
          Double tap R on your keyboard to reload,{'\n'}
          Shake or press menu button for dev menu
        </Text>
        <Image source={pic} style={{width: 193, height: 110}}/>
        <MText text="我是闪屏大王"/>
      </View>
    );
  }
}